package com.milo.thread.lock;

/**
 * @author: Milogenius
 * @create: 2019-04-28 10:40
 * @description: 演示synchronized是重入锁
 **/
public class SynchronizedTest implements Runnable {

    public synchronized void get() {
        System.out.println(Thread.currentThread().getName());
        set();
    }

    public synchronized void set() {
        System.out.println(Thread.currentThread().getName());
    }

    @Override
    public void run() {
        get();
    }


    public static void main(String[] args) {
        SynchronizedTest rt = new SynchronizedTest();
        for (; ; ) {
            new Thread(rt).start();
        }
    }

}
